package ShapeDiamond;

import java.util.Scanner;

/**
 * Created by Nishi on 24/12/13.
 *  Display asterisks in Isosceles triangle and diamond shapes
 */
public class Diamond {
    public static void main(String[] args) {

        System.out.println("Enter a whole number : ");
        Scanner read = new Scanner(System.in);
        String input = read.nextLine();
        int lineNumber = Integer.parseInt(input);

        System.out.println("Isosceles Triangle");
        displayIsoscelesTriangle(lineNumber);

        System.out.println("Diamond");
        displayIsoscelesTriangle(lineNumber);
        displayBottomDiamond(lineNumber);

        System.out.println("Diamond with name displayed");
        displayIsoscelesTriangle(lineNumber-1);
        System.out.println("Nishi");
        displayBottomDiamond(lineNumber);

    }

    private static void displayIsoscelesTriangle(int count) {
        int blank = count;
        for( int i = 1 ;i <= count ;i++){
            int max = 2*i-1;

            blank--;
            for (int k = blank; k > 0 ;k--){
                System.out.print(" ");
            }

            for( int j = 1 ; j <= max; j++){
                System.out.print("*");

            }

            System.out.println();
        }

    }

    private static void displayBottomDiamond(int count) {
        int blank=0;
        for (int downRows = count-1;downRows > 0;downRows--){
            int oddNumber = 2*downRows-1;
            blank++;
            for ( int space = blank; space>0; space--){
                System.out.print(" ");
            }

            for( int j = 1 ; j <= oddNumber; j++){
                System.out.print("*");
            }
            System.out.println();

        }
    }


}
